package middleware

import (
	"Demo_Gin/model/auth"
	"github.com/gin-gonic/gin"
)

const (
	HEADER_AUTH        = "Authorization"
	HEADER_AUTH_PREFIX = "Bearer "
)

// MockSetLoginInfo 模拟登录用户信息
func MockSetLoginInfo(ctx *gin.Context) {
	if _, ok := ctx.Get("user"); !ok {
		loginUser := &auth.LoginUser{
			UID:    "xiaoming",
			Name:   "小明",
			Roles:  []string{"USER"},
			Avatar: "https://picsum.photos/250?random=1",
		}
		ctx.Set("user", loginUser) //存储到gin上下文 登录用户信息
	}
	ctx.Next() //放行，执行下去
}
